package com.friday.bo.impl;

import com.friday.bo.LoginBo;
import com.friday.dao.EmployeeDao;
import com.friday.dao.impl.EmployeeDaoImpl;
import com.friday.po.Employee;

public class LoginBoImpl implements LoginBo {

	@Override
	public int verify(String account, String password) throws Exception {
		int ret = 0;
		EmployeeDao employeeDao = new EmployeeDaoImpl();
		
		Employee emp = employeeDao.queryEmployeesByAccount(account);
		
		if(emp != null) {
			if(emp.getPassword().equals(password)) {
				ret = 1;
			}
			else {
				ret = 0;
			}
		}
		else {
			ret = 0;
		}
		
		return ret;
	}

	@Override
	public int getActorByAccount(String account) throws Exception {
		EmployeeDao employeeDao = new EmployeeDaoImpl();
		
		Employee emp = employeeDao.queryEmployeesByAccount(account);
		
		return emp.getActor();
	}

	@Override
	public String getNameByAccount(String account) throws Exception {
		EmployeeDao employeeDao = new EmployeeDaoImpl();
		
		Employee emp = employeeDao.queryEmployeesByAccount(account);
		
		return emp.getName();
	}

	@Override
	public String getIdByAccount(String account) throws Exception {
		EmployeeDao employeeDao = new EmployeeDaoImpl();
		
		Employee emp = employeeDao.queryEmployeesByAccount(account);
		
		return emp.getId();
	}

}
